home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Turnbull China Bikeride
/
Turnbull China Bikeride - Disc 1.iso
/
ARGONET
/
PD
/
PROGRAMMING
/
DESKLIBC
/
SOURCES.ZIP
/
DeskLib
/
!DLSources
/
Libraries
/
Mem
/
c
/
Compact
< prev
next >
Wrap
Text File
|
1995-06-18
|
2KB
|
41 lines
/*
#### # # # #
# # # # # The FreeWare C library for
# # ## ### # # # # ### RISC OS machines
# # # # # # # # # # # ___________________________________
# # #### ### ## # # # #
# # # # # # # # # # Please refer to the accompanying
#### ### #### # # ##### # ### documentation for conditions of use
________________________________________________________________________
File: Mem.Compact.c
Author: Copyright © 1993, 1994, 1995 Jason Williams and Jason Howat
Version: 2.00 (18 Jun 1995)
Purpose: Dynamic memory manager - heap compaction
*/
#include "MemDefs.h"
extern void Mem_Compact(void)
/* Compacts the heap, moving all freespace to the end of the heap, and then
* releases as much of this freespace as possible back into the WIMP freepool.
*/
{
if (mem__free < mem__pagesize) return; /* Don't compact if not necessary */
/* Gather all used chunks at beginning of heap */
Mem__ShuffleDown((mem_header *)mem__heap,
(mem_header *)(mem__heap + mem__heapsize));
/* Adjust the WimpSlot to the minimum that we require, adjusting the last
* chunk as appropriate
*/
Mem__ReduceSlot();
/* Update the count of free bytes in the heap */
if(ISFREE(mem__lastchunk))
mem__free = mem__lastchunk->realsize;
else
mem__free = mem__lastchunk->realsize - CHUNKSIZE(mem__lastchunk->datasize);
}